// sideBar.js
Component({
  properties: {
    show: {
      type: Object,
      value: false,
      observer(val, oldVal) {
        this.setData({
          isShow: val.show
        })
      }
    },

    labels: {
      type: Array,
      value: []
    }
  },

  attached() {
    this.setData({
      isShow: this.properties.show.show
    })
  },

  data: {
    isShow: false,
    activeNames: ['1'],
    search: ''
  },

  methods: {
    onClose() {
      this.setData({
        isShow: false
      })
    },

    onChange(e) {
      this.setData({
        activeNames: e.detail
      })
    },

    searchOnChange(e) {
      this.setData({
        search: e.detail
      })
    },

    onSearch() {
      if (this.data.search) {
        wx.navigateTo({
          url: '/pages/category/category?search=' + this.data.search,
        })
      }
    },

    handleMenuClick(e) {
      let label = e.currentTarget.dataset.info.name
      wx.navigateTo({
        url: '/pages/category/category?label=' + label,
      })
    }
  }
})